package com.ruoyi.celoan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.celoan.entity.ExtradeEffectLoginLogEntity;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ExtradeEffectLoginLogMapper extends BaseMapper<ExtradeEffectLoginLogEntity> {

    @Select("SELECT " +
            "sl.enterprise_name, " +
            "sl.user_name, " +
            "sl.unisc_id, " +
            "'1306' AS platform_id, " +
            "sl.login_name, " +
            "sl.login_time, " +
            "sl.ipaddr AS login_ip, " +
            "IF(sl.`status`=1,'成功','失败') AS login_status," +
            "'0' AS isflag " +
            "FROM sys_logininfor sl " +
            "LEFT JOIN login_log_report l ON l.id = sl.info_id " +
            "WHERE " +
            "sl.login_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01') " +
            "AND sl.unisc_id IS NOT NULL AND l.id IS NULL")
    List<ExtradeEffectLoginLogEntity> selectLoginLogList();
}
